 /* 
  * Copyright (C) 2012 maxim 
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
  * published by the Free Software Foundation; either version 2 of the
  * License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  */


#include "tests.h"

#include "user_threads.h"
#include "user_mutex.h"

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

#include <sys/types.h>
#include <sys/wait.h>


/* Two threads try to join thread #0 */

static int thread1(void *arg)
{
	uthread_join(0, NULL);
}

static int thread2(void *arg)
{
	assert (uthread_join(0, NULL) == UTHREAD_FAIL);
}

void test10()
{

	msg("\nRunning test #10...");
	int pid;
	pid = fork();

	if (!pid) {
		msg("\nRunning test #10...");
		uthread_create(thread1, NULL);
		uthread_create(thread2, NULL);
		uthread_yield();
		exit(0);
	}

	else
		waitpid(pid, NULL, 0);
}
